package com.schedule.task.advice;

import com.schedule.task.exception.Adexception;
import com.schedule.task.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(value = Adexception.class)
    public CommonResponse<String> handleAdException(HttpServletRequest req, Adexception ex) {
        CommonResponse<String> response = new CommonResponse<>(-1, "my error");
        response.setData(ex.getMessage());
        return response;
    }
}
